package org.example.ch01.p02;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextLine()) {
            String s = scanner.nextLine().trim();
            if (s.isEmpty()) continue;
            try {
                int num = Integer.parseInt(s);
                if (num >= 10000 && num <= 20000) {
                    System.out.println(Integer.toBinaryString(num) + "," +
                            Integer.toOctalString(num) + "," +
                            Integer.toHexString(num));
                } else {
                    processDigits(s);
                }
            } catch (Exception e) {
                processDigits(s);
            }
        }
        scanner.close();
    }

    private static void processDigits(String s) {
        int sum = 0;
        StringBuilder sb = new StringBuilder();
        boolean negative = s.charAt(0) == '-';
        for (int i = negative ? 1 : 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (Character.isDigit(c)) {
                int d = c - '0';
                sb.append(c).append(" ");
                sum += d;
            }
        }
        if (sb.length() > 0) {
            sb.setLength(sb.length() - 1);
        }
        System.out.println(sb.toString() + (sb.length() > 0 ? " " + sum : ""));
    }
}
